<template>
    <a-card :bordered="false">

        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
            <a-form layout="inline" @keyup.enter.native="searchQuery1">
                <a-row :gutter="24">
                    <a-col :md="6" :sm="12">
                        <a-form-item label="创建时间">
                            <a-date-picker format='YYYY-MM-DD' :value="queryParam.createTime_begin" style="width: 45%;"  placeholder="请选择开始时间" size="small" :allowClear="false"  @change="changeBegin" suffixIcon=" "/>
                            <span> 至 </span>
                            <a-date-picker format='YYYY-MM-DD' :value="queryParam.createTime_end" style="width: 45%;"  placeholder="请选择结束时间" size="small" :allowClear="false"  @change="changeEnd" suffixIcon=" "/>
                        </a-form-item>
                    </a-col>
                    <a-col :md="6" :sm="12">
                        <a-form-item label="订单类型">
                            <j-dict-select-tag v-model="queryParam.orderType" placeholder="请选择订单类型" size="small"
                                dictCode="order_type" />
                        </a-form-item>
                    </a-col>
                    <a-col :md="6" :sm="12">
                        <a-form-item label="订单状态">
                            <j-dict-select-tag v-model="queryParam.status" placeholder="请选择订单状态" size="small"
                                dictCode="order_status" />
                        </a-form-item>
                    </a-col>
                    <a-col :md="6" :sm="12">
                        <a-form-item label="经销商">
                            <a-select show-search v-model="queryParam.customerCode" placeholder="请输入经销商名称" size="small"
                                :default-active-first-option="false" :show-arrow="false" :filter-option="false"
                                :not-found-content="null" @search="handleSearch" @change="handleChange" allowClear>
                                <a-select-option v-for="d in storeList" :key="d.value" :title="d.label + d.value">
                                    <p class="small">{{ d.label }}{{ d.value }}</p>
                                </a-select-option>
                            </a-select>
                        </a-form-item>
                    </a-col>

                    <a-col :md="6" :sm="12">
                        <a-form-item label="跟单员">
                            <a-select v-model="queryParam.saleUserName" size="small"
                                :getPopupContainer="node => node.parentNode" style="width: 100%" placeholder="请选择跟单员"
                                @change="$forceUpdate()" :key="queryParam.saleUserName" allowClear>
                                <a-select-option v-for="s in merchandiserList" :key="s.value" :value="s.label">
                                    {{ s.label }}
                                </a-select-option>
                            </a-select>
                        </a-form-item>
                    </a-col>
                    <a-col :md="6" :sm="12">
                        <a-form-item label="渠道">
                            <a-select v-decorator="['channelId', {}]" v-model="queryParam.channelId" style="width: 100%"
                                :getPopupContainer="node => node.parentNode" placeholder="请选择渠道" allowClear
                                size="small">
                                <a-select-option v-for="(channel, channelIdIndex) in ChannelList"
                                    :key="channel.id.toString()" :value="channel.channelId">
                                    {{ channel.name }}
                                </a-select-option>
                            </a-select>
                        </a-form-item>
                    </a-col>
                    <a-col :md="6" :sm="12">
                        <a-form-item label="订单编号">
                            <a-input placeholder="请输入订单编号" v-model="queryParam.orderNo" size="small"></a-input>
                        </a-form-item>
                    </a-col>
                    <a-col :md="6" :sm="12">
                        <span style="margin:2px 0; display: inline-block;font-size: 12px;">
                            <span>当日订单</span>
                            <a-checkbox :checked="ynToday" @change="onDateChange"></a-checkbox>
                        </span>
                        <span style="margin:0 7px; display: inline-block;" class="table-page-search-submitButtons">
                            <a-button type="primary" size="small" @click="searchQuery1" icon="search">查询</a-button>
                            <a-button @click="searchReset1" size="small" icon="reload"
                                style="margin-left: 7px;">重置</a-button>
                        </span>

                        <a-button size="small" icon="download" @click="handleExportXls('订单管理')">导出</a-button>
                    </a-col>
                </a-row>
            </a-form>
        </div>
        <!-- table区域-begin -->
        <div>
            <!-- <div class="ant-alert ant-alert-info">
                <i class="anticon anticon-info-circle ant-alert-icon"></i>
                <span>已选择</span>
                <a style="font-weight: 600">
                    {{ selectedRowKeys.length }}
                </a>
                <span>项</span>
                <a style="margin-left: 24px" @click="onClearSelected">清空</a>
            </div> -->
            <!-- selectedRowKeys: selectedRowKeys,
                :rowSelection="{  onChange: onSelectChange }" -->
            <!-- 1662  -->
            <a-table ref="table" virtual size="small" bordered rowKey="id" :scroll="{ x: 1662, y: height }"
                :columns="columns" id="orderTable" :dataSource="dataSource" :pagination="ipagination" :loading="loading"
                @change="handleTableChange" :components="componentsResize" :style="{ '--cssHeight': height + 'px' }">
                <template slot="dealerName" slot-scope="text, record">
                    <!-- 状态!= 0 -->
                    <span v-if="record.status != 0" class="ellipsis pointer" @click="handleShowDetail(record)"
                        :title="record.storeId_dictText">{{ companyNameFormat(record.storeId_dictText) }}</span>
                    <!-- 有权限 且 状态==0 -->
                    <span v-else>
                        <a href="javascript:;" v-has="'order:adminAprove'" @click="handleEditApply(record)"
                            class="ellipsis" :title="record.storeId_dictText">{{
                                companyNameFormat(record.storeId_dictText) }}</a>
                        <!-- 无权限 且 状态==0  -->
                        <span v-hasnot="'order:adminAprove'" class="ellipsis pointer" :title="record.storeId_dictText"
                            @click="handleShowDetail(record)">{{ companyNameFormat(record.storeId_dictText) }}</span>
                    </span>
                </template>

                <template slot="ellipsisName" slot-scope="text, record">
                    <span class="ellipsis" :title="text" @click="handleShowDetail(record)">{{ companyNameFormat(text)
                        }}</span>
                </template>
                <template slot="payAmount" slot-scope="text, record">
                    <span class="payAmount" :title="text" @click="handleShowDetail(record)">{{ text.toFixed(2) }}</span>
                </template>
                <template slot="b2bTime" slot-scope="text, record">
                    <span class="b2bTime" v-if="text" @click="handleShowDetail(record)">{{ text }}</span>
                </template>
                <template slot="sapTime" slot-scope="text, record">
                    <span class="sapTime" v-if="text">{{ text }}</span>
                </template>

                <!-- <span slot="action" slot-scope="text, record">
                    <a-button type="link" class="tableBtn" @click="handleShowDetail(record)">详情</a-button>
                    <a-button type="link" class="tableBtn" @click="handleEditApply(record)" v-if="record.status == 0"
                        v-has="'order:adminAprove'">跟单员审核</a-button>
                    <a-popconfirm title="确定反审核吗?" v-else-if="record.status == 1" v-has="'order:contraryApprove'"
                        placement="topLeft" @confirm="() => handleAnti(record.id, 1)">
                        <a-button type="link" class="tableBtn danger">反审核</a-button>
                    </a-popconfirm>
                    <a-popconfirm title="确定撤销初审吗?" v-else-if="record.status == 5" v-has="'order:cancelApprove'"
                        placement="topLeft" @confirm="() => handleAnti(record.id, 0)">
                        <a-button type="link" class="tableBtn danger">撤销初审</a-button>
                    </a-popconfirm>
                </span> -->
            </a-table>
        </div>
        <!-- table区域-end -->

        <!-- 表单区域 -->
        <!-- <omsOrder-modal ref="modalForm" @ok="modalFormOk" /> -->

        <!-- <oms-order-modal-j-x ref="OmsOrderModalJX" @ok="modalFormOk" /> -->

        <!-- <omsRequiregoods-modalJX ref="modalOAForm" @ok="modalFormOk" /> -->

        <oms-order-view-modalJX ref="OmsOrderViewModalJX" @ok="modalFormOk" @handleTrace="handleTrace" />

        <!-- <oms-order-process-memo-modal ref="OmsOrderProcessMemoModal" @ok="modalFormOk" /> -->

        <!-- <oms-order-edit-logistics-modalJX ref="OmsOrderEditLogisticsModalJX" @ok="modalFormOk" /> -->

        <oms-order-edit-apply-modalJX ref="OmsOrderEditApplyModalJX" @ok="modalFormOk" @handleTrace="handleTrace" />

        <!-- <oms-order-edit-freight-modal ref="OmsOrderEditFreightModal" @ok="modalFormOk" /> -->

        <oms-order-trace-modalJX ref="OmsOrderTraceModalJX" @ok="modalFormOk" />
        <oms-order-logistics-modal ref="OmsOrderLogisticsModal" />
        <!-- <oms-order-finance-edit-apply-modalJX ref="OmsOrderFinanceEditApplyModalJX" @ok="modalFormOk" /> -->
        <!-- <omsOrderLogisticsEditApplyModalJX ref="OmsOrderLogisticsEditApplyModalJX" @ok="modalFormOk" /> -->
        <!-- <omsOrderEditPriceModalJX ref="OmsOrderEditPriceModalJX" @ok="modalFormOk" /> -->
        <a-modal :width="800" :visible="logisticsInfo.visible" :footer="null" :closable="false" :maskClosable="false"
            style="top: 20px">
            <div style="width: 100%;height: 360px;" v-if="logisticsInfo.visible">
                <iframe style="width: 100%;height: 100%;"
                    :src="'https://bi.flyco.net.cn/webroot/decision/view/report?viewlet=flyco-b2b%252Fb2b_order_logistics_detail.cptx&billno=' + logisticsInfo.choiseId"
                    frameborder="0"></iframe>
            </div>
            <div style="display: flex;justify-content: center;">
                <a-button type="primary" @click="logisticsInfo.visible = false">关闭</a-button>
            </div>
        </a-modal>
    </a-card>
</template>

<script>

import { httpAction, downFile, getAction, deleteAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import moment from 'moment'
import OmsOrderModal from './modules/OmsOrderModal'
import OmsOrderModalJX from './modules/OmsOrderModalJX'
import OmsOrderViewModalJX from './modules/OmsOrderViewModalJX'
import OmsOrderEditLogisticsModalJX from './modules/OmsOrderEditLogisticsModalJX'
import OmsOrderEditApplyModalJX from './modules/OmsOrderEditApplyModalJX'
import OmsOrderEditFreightModal from './modules/OmsOrderEditFreightModal'
import OmsOrderProcessMemoModal from './modules/OmsOrderProcessMemoModal'
import OmsOrderTraceModalJX from './modules/OmsOrderTraceModalJX'
import JMultiSelectTag from '../../components/dict/JMultiSelectTag'
import OmsRequiregoodsModalJX from './modules/OmsRequiregoodsModalJX'
import OmsOrderFinanceEditApplyModalJX from './modules/OmsOrderFinanceEditApplyModalJX'
import OmsOrderLogisticsEditApplyModalJX from './modules/OmsOrderLogisticsEditApplyModalJX'
import OmsOrderEditPriceModalJX from './modules/OmsOrderEditPriceModalJX'
import OmsOrderLogisticsModal from './modules/OmsOrderLogisticsModal'
import { dragResizableFunc } from '@/utils/draggable-resizable.js';
export default {
    name: 'OmsOrderListJX',
    mixins: [JeecgListMixin],
    components: {
        JMultiSelectTag,
        OmsRequiregoodsModalJX,
        OmsOrderModal,
        OmsOrderViewModalJX,
        OmsOrderEditLogisticsModalJX,
        OmsOrderEditApplyModalJX,
        OmsOrderEditFreightModal,
        OmsOrderProcessMemoModal,
        OmsOrderTraceModalJX,
        OmsOrderModalJX,
        OmsOrderFinanceEditApplyModalJX,
        OmsOrderLogisticsEditApplyModalJX,
        OmsOrderEditPriceModalJX,
        OmsOrderLogisticsModal
    },
    data() {
        let _this = this;
        return {
            // 物流相关信息
            logisticsInfo: {
                visible: false,
                choiseId: "",
            },
            ipagination: {
                current: 1,
                pageSize: 30,
                pageSizeOptions: ['10', '30', '50', '100', '200', '1000'],
                showTotal: (total, range) => {
                    return range[0] + "-" + range[1] + " 共" + total + "条"
                },
                showQuickJumper: true,
                showSizeChanger: true,
                total: 0
            },
            ChannelList: [],
            dataTimes: [],
            ynToday: false,
            // 表头
            columns: [
                {
                    title: '序号',
                    dataIndex: '',
                    key: 'rowIndex',
                    width: 43,
                    align: 'center',
                    // fixed: 'left',
                    // customRender: (t, r, index) => {
                    //     return Number(this.ipagination.pageSize * (this.ipagination.current - 1)) + Number(index) + 1
                    // }
                    customRender: (t, r, index) => {
                        return {
                            children: this.$createElement(
                                'span',
                                {
                                    class: 'pointer',
                                    on: {
                                        click: () => {
                                            _this.handleShowDetail(r)
                                        }
                                    }
                                },
                                Number(this.ipagination.pageSize * (this.ipagination.current - 1)) + Number(index) + 1
                            )
                        }
                    }
                },
                // {
                //     title: '经销商编码',
                //     width: 110,
                //     align: 'center',
                //     dataIndex: 'customerCode'
                // },
                // {
                //     title: '渠道',
                //     width: 100,
                //     align: 'center',
                //     dataIndex: 'channelName'
                // },
                {
                    title: '订单编号',
                    width: 116,
                    align: 'center',
                    sorter: true,
                    dataIndex: 'orderNo',
                    // fixed: 'left',
                    customRender: (t, r, index) => {
                        return {
                            children: this.$createElement(
                                'span',
                                {
                                    class: 'pointer',
                                    on: {
                                        click: () => {
                                            _this.handleShowDetail(r)
                                        }
                                    }
                                },
                                t
                            )
                        }
                    }
                },
                {
                    title: '经销商',
                    width: 160,
                    align: 'left',
                    dataIndex: 'company_name',
                    sorter: true,
                    scopedSlots: { customRender: 'dealerName' },
                    // fixed: 'left',
                    ynDraggable: true
                },
                {
                    title: '客户仓库',
                    width: 160,
                    align: 'left',
                    dataIndex: 'stockName',
                    sorter: true,
                    scopedSlots: { customRender: 'ellipsisName' },
                    ynDraggable: true
                },
                // {
                //     title: '订单状态',
                //     width: 110,
                //     align: 'center',
                //     dataIndex: 'status_dictText'
                // },
                // {
                //     title: '商品金额',
                //     width: 100,
                //     align: 'center',
                //     dataIndex: 'totalAmount'
                // },
                {
                    title: '应付金额',
                    width: 88,
                    align: 'right',
                    scopedSlots: { customRender: 'payAmount' },
                    sorter: true,
                    dataIndex: 'payAmount',
                },
                // {
                //     title: '收货人',
                //     width: 100,
                //     align: 'center',
                //     dataIndex: 'receiverName'
                // },
                {
                    title: '提交时间',
                    width: 120,
                    align: 'center',
                    dataIndex: 'createTime',
                    sorter: true,
                    scopedSlots: { customRender: 'b2bTime' },
                },
                {
                    title: '初审时间',
                    width: 120,
                    align: 'center',
                    dataIndex: 'applyTime',
                    sorter: true,
                    scopedSlots: { customRender: 'b2bTime' },

                },
                {
                    title: '复审时间',
                    width: 120,
                    align: 'center',
                    dataIndex: 'checkTime',
                    sorter: true,
                    scopedSlots: { customRender: 'b2bTime' },
                },
                {
                    title: '出库时间',
                    width: 125,
                    align: 'center',
                    dataIndex: 'outboundTime',
                    sorter: true,
                    scopedSlots: { customRender: 'b2bTime' },
                },
                {
                    title: '物流提货时间',
                    width: 120,
                    align: 'center',
                    sorter: true,
                    dataIndex: 'logisticsPickupTime',
                    scopedSlots: { customRender: 'sapTime' },
                    customRender: (t, r, index) => {
                        return {
                            children: this.$createElement(
                                'div',
                                {
                                    class: 'sapTime',
                                    on: {
                                        click: () => {
                                            this.logisticsInfo.choiseId = r.stockBillNo
                                            this.logisticsInfo.visible = true
                                        }
                                    }
                                },
                                t
                            )
                        }
                    }
                },
                {
                    title: '物流发货时间',
                    width: 120,
                    align: 'center',
                    sorter: true,
                    dataIndex: 'logisticsShipmentTime',
                    scopedSlots: { customRender: 'sapTime' },
                    customRender: (t, r, index) => {
                        return {
                            children: this.$createElement(
                                'div',
                                {
                                    class: 'sapTime',
                                    on: {
                                        click: () => {
                                            this.logisticsInfo.choiseId = r.stockBillNo
                                            this.logisticsInfo.visible = true
                                        }
                                    }
                                },
                                t
                            )
                        }
                    }

                },
                {
                    title: '物流到货时间',
                    width: 120,
                    align: 'center',
                    sorter: true,
                    dataIndex: 'logisticsArrivalTime',
                    scopedSlots: { customRender: 'sapTime' },
                    customRender: (t, r, index) => {
                        return {
                            children: this.$createElement(
                                'div',
                                {
                                    class: 'sapTime',
                                    on: {
                                        click: () => {
                                            this.logisticsInfo.choiseId = r.stockBillNo
                                            this.logisticsInfo.visible = true
                                        }
                                    }
                                },
                                t
                            )
                        }
                    }

                },
                {
                    title: '结案时间',
                    width: 125,
                    align: 'center',
                    sorter: true,
                    dataIndex: 'receiveTime',
                    scopedSlots: { customRender: 'b2bTime' },
                },
                {
                    title: 'SAP单号',
                    align: 'center',
                    width: 123,
                    dataIndex: 'vbeln',
                    customRender: (t, r, index) => {
                        return {
                            children: this.$createElement(
                                'span',
                                {
                                    class: 'pointer',
                                    on: {
                                        click: () => {
                                            _this.handleShowDetail(r)
                                        }
                                    }
                                },
                                t
                            )
                        }
                    }
                },
                // {
                //     title: '操作',
                //     width: 120,
                //     dataIndex: 'action',
                //     align: 'center',
                //     fixed: 'right',
                //     scopedSlots: { customRender: 'action' }
                // }
            ],
            description: '订单管理页面',
            url: {
                list: '/oms/omsOrder/list',
                payment: '/oms/omsOrder/payment',
                lockTime: '/oms/omsOrder/editLockTime',
                delete: '/oms/omsOrder/delete',
                deleteBatch: '/oms/omsOrder/deleteBatch',
                exportXlsUrl: 'oms/omsOrder/exportXls',
                exportXlsOrderItemUrl: 'oms/omsOrder/exportOrderItemXls',
                importExcelUrl: 'oms/omsOrder/importExcel',
                exportXlsForFinance: 'oms/omsOrder/exportXlsForFinance',
                channelListUrl: 'stm/stmChannelInfo/list',
                anti: '/oms/omsOrder/antiApprove',
                OrderSendQuantity: '/oms/omsOrder/getOrderSendQuantity',
                getCurrentUserUrl: 'sys/userV2/getCurrentUser',
                getStoreList: 'stm/stmStoreInfo/getDropDownList',
                getMerchandiserList: 'sys/user/getDropDownList'
            },
            disableMixinCreated: true,
            storeList: [],
            merchandiserList: [],
            height: 800,
            width: 1605
        }

    },
    computed: {
        importExcelUrl: function () {
            return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
        },
        componentsResize() {
            return dragResizableFunc(this.columns);
        },
    },
    // 计算表格最大高度
    created() {
        let lastDayOfMonth = moment().endOf('month').format('YYYY-MM-DD');
        let startDayOfMonth = moment().startOf('month').format('YYYY-MM-DD');
        this.dataTimes = [startDayOfMonth, lastDayOfMonth]
        this.onCreateTimeChange('', this.dataTimes)
        this.getMerchandiserList();
        this.getChannelList();
        // 59px + 52px + 12px  + 43px = 166
        this.height = window.innerHeight - 166 - 170
        this.$nextTick(() => {
            let ele = document.getElementById('orderTable')
            if (ele) {
                this.width = Math.max(ele.offsetWidth, 1605)
                console.log(this.width);
            }

        })
    },
    methods: {
        moment,
        onCreateTimeChange: function (value, dateString) {
            this.queryParam.createTime_begin = dateString[0] + ' 00:00:00'
            this.queryParam.createTime_end = dateString[1] + ' 23:59:59'
        },
        changeBegin(date,dateString){
            if(this.queryParam.createTime_end && dateString > this.queryParam.createTime_end.split(' ')[0]){
                this.$message.warning('开始时间需小于结束时间')
                return;
            }
            this.$set(this.queryParam,'createTime_begin',dateString + ' 00:00:00')
            this.$forceUpdate();
        },
        changeEnd(date,dateString){
            if(this.queryParam.createTime_begin && dateString < this.queryParam.createTime_begin.split(' ')[0]){
                this.$message.warning('结束时间需大于开始时间')
                return;
            }
            this.$set(this.queryParam,'createTime_end',dateString + ' 23:59:59')
            this.$forceUpdate();
        },

        handleProcess(record, status) {
            console.log('1->');
            console.log(status);
            this.$refs.modalOAForm.add(record.id)
            this.$refs.modalOAForm.title = '订单审核'
        },
        handleShowDetail(record) {
            this.$refs.OmsOrderViewModalJX.show(record)
        },
        handleProcessMemo(record) {
            this.$refs.OmsOrderProcessMemoModal.show(record)
        },
        handleTrace(record) {
            this.$refs.OmsOrderTraceModalJX.show(record)
        },
        handleAdd() {
            this.$refs.OmsOrderModalJX.show()
        },
        // 跟单员审核
        handleEditApply(record) {
            // if (record.status == 9) {
            //     this.$refs.OmsOrderFinanceEditApplyModalJX.show(record)
            // } else if (record.status == 10) {
            //     this.$refs.OmsOrderLogisticsEditApplyModalJX.show(record)
            // } else {

            this.$refs.OmsOrderEditApplyModalJX.show(record)
            // }
        },
        handleEditPrice(record) {
            this.$refs.OmsOrderEditPriceModalJX.show(record)
        },
        handleEditLogisticsApply(record) {
            this.$refs.OmsOrderEditLogisticsModalJX.show(record)
        },
        handleEditFreight(record) {
            if (record.status === 0) {
                this.$refs.OmsOrderEditFreightModal.show(record)
            } else {
                this.$message.warning('订单：' + record.id + ' 当前已不可修改价格')
            }
        },
        onDateChange(e) {
            this.ynToday = e.target.checked
            if (e.target.checked) {
                let time = moment().format("YYYY-MM-DD");
                this.queryParam.createTime_begin = time + ' 00:00:00'
                this.queryParam.createTime_end = time + ' 23:59:59'
            } else {
                this.queryParam.createTime_begin = ''
                this.queryParam.createTime_end = ''
            }
            this.searchQuery1()
        },
        searchQuery1() {
            this.searchQuery()
        },
        searchReset1() {
            this.dataTimes = [];
            this.queryParam.createTime_begin = ''
            this.queryParam.createTime_end = ''
            this.ynToday = false
            this.searchReset()
        },
        getChannelList() {
            let param = {};
            param.status = 1;
            param.pageSize = 100;
            getAction(this.url.channelListUrl, param).then(res => {
                if (res.success) {
                    this.ChannelList = res.result.records;
                    // this.ChannelList.push({ id: "", name: "请选择渠道" })
                    // this.ChannelList.reverse();
                } else {
                    console.log(res.message)
                }
            })
        },
        /***获取跟单员列表 */
        getMerchandiserList() {
            getAction(this.url.getMerchandiserList, {}).then(res => {
                if (res.success) {
                    this.merchandiserList = res.result;
                    this.getCurrentUser();
                } else {
                    console.log(res.message)
                }
            })
        },
        /**获取当前用户是否是跟单员*/
        getCurrentUser() {
            getAction(this.url.getCurrentUserUrl, {}).then(res => {
                if (res.success && res.result.orderCheckUserFlag == 1) {
                    //如果是跟单员，跟单员条件默认带出登录人姓名
                    this.queryParam.saleUserName = res.result.realname;
                }
                this.disableMixinCreated = false
                this.loadData()
            }).catch(() => {
                this.disableMixinCreated = false
                this.loadData()
            })
        },
        handleExportOrderItem(fileName) {
            if (!fileName || typeof fileName != "string") {
                fileName = "导出文件"
            }
            let param = { ...this.getQueryParams() };
            if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
                param['selections'] = this.selectedRowKeys.join(",")
            }
            console.log("导出参数", param)
            downFile(this.url.exportXlsOrderItemUrl, param).then((data) => {
                if (!data) {
                    this.$message.warning("文件下载失败")
                    return
                }
                if (typeof window.navigator.msSaveBlob !== 'undefined') {
                    window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xls')
                } else {
                    let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
                    let link = document.createElement('a')
                    link.style.display = 'none'
                    link.href = url
                    link.setAttribute('download', fileName + '.xls')
                    document.body.appendChild(link)
                    link.click()
                    document.body.removeChild(link); //下载完成移除元素
                    window.URL.revokeObjectURL(url); //释放掉blob对象
                }
            })
        },


        //   反审核
        handleAnti(orderId, status = 0) {

            httpAction(this.url.anti, { id: orderId, status }, 'put').then((res) => {
                if (res.success) {
                    this.$message.success(res.message);
                    this.loadData();
                } else {
                    this.$message.warning(res.message)
                }
            })
        },

        getOrderSendQuantity(record) {
            var that = this
            getAction(that.url.OrderSendQuantity, { orderId: record.id }).then((res) => {
                if (res.success) {
                    let count = parseInt(res.result);
                    if (count > 0) {
                        this.$confirm({
                            title: "确认废除",
                            content: "存在已发货的出库单，请再次确认！",
                            onOk: function () {
                                that.handleRepeal(record.id);
                            }
                        });
                    } else {
                        that.handleRepeal(record.id);
                    }

                } else {
                    that.$message.warning(res.message)
                }
            })

        },
        // 经销商搜索
        handleSearch(value) {
            if (!value) {
                return;
            }
            getAction(this.url.getStoreList, { storeName: value }).then(res => {
                if (res.success) {
                    this.storeList = res.result;
                } else {
                    console.log(res.message)
                }
            })
        },
        // 经销商搜索
        handleChange(value) {
            console.log(value);
        },
        // 订单与物流信息
        openLogisticsModal(record) {
            this.$refs.OmsOrderLogisticsModal.show(record)
        },
        companyNameFormat(name) {
            return name && name.length > 14 ? name.replace('有限公司', '..') : name
        }



        // /* 打开销售报表 */
        // toReport(){
        //   window.open('https://bi.flyco.net.cn/webroot/decision/view/report?viewlet=jx_report%252FJX_OMS_ORDER.cpt&ref_t=design&ref_c=a1282087-d3e8-4375-8e56-641e3628d0f5')
        // }
    }
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';

/deep/ .ant-form-item label,
/deep/ .ant-calendar-picker,
/deep/ .ant-select,
/deep/ .ant-form-item,
/deep/ .ant-input,
/deep/ .ant-btn-sm {
    font-size: 12px;
}

.small,
.tableBtn {
    font-size: 12px;
}

.ellipsis {
    // max-width: 120px;
    display: block;
    margin: 0 auto;
    cursor: pointer;
}

/deep/ .ant-card-body {
    padding: 10px 12px;
}

/deep/ .table-page-search-wrapper .ant-form-inline .ant-form-item,
/deep/ .table-page-search-wrapper .table-page-search-submitButtons {
    margin-bottom: 8px;
}

/deep/ .table-operator .ant-btn {
    margin-bottom: 0;
}

/deep/ #orderTable .ant-table {
    font-size: 12px !important;
    font-family: Arial;
}

/deep/ #orderTable .ant-table-body {
    height: var(--cssHeight);
}

#orderTable /deep/ tr>td,
#orderTable /deep/ td {
    padding: 0 !important;
    height: 1px;
}

#orderTable /deep/ .ant-table-bordered .ant-table-thead>tr>th,
#orderTable /deep/ .ant-table-small,
#orderTable /deep/ td {
    border-color: #c6c6c6 !important;
}

#orderTable /deep/ .ant-table-pagination.ant-pagination {
    margin: 12px 0 0;
}

/deep/ #orderTable .ant-table-body::-webkit-scrollbar {
    width: 6px; //或者15px
    height: 6px;
}

/deep/ #orderTable .ant-table-small>.ant-table-content .ant-table-row:last-child td {
    border-bottom: 1px solid #e8e8e8;
}

.b2bTime {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #F4BE6A;
    cursor: pointer;
}

.sapTime {
    background: #b3ffa4;
    cursor: pointer;
    text-decoration: underline;
    cursor: pointer;

}

.payAmount {
    padding-right: 5px;
    cursor: pointer;
}

/deep/ .resize-table-th {
    position: relative;
    z-index: 999;
}

/deep/ .table-draggable-handle {
    height: 100% !important;
    left: auto !important;
    right: -5px;
    cursor: col-resize;
    touch-action: none;
    border: none;
    z-index: 999;
    top: 0;
    position: absolute;
    transform: none !important;
}
</style>
